# $Id$
# Maintainer (ArchLinux): Andrea Scarpino <andrea@archlinux.org>
# Maintainer (MSYS2): Ray Donnelly <mingw.android@gmail.com>
# Contributor: Zach Bacon <zachbacon@vba-m.com>

_variant=-${KF5_VARIANT:-shared}
source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_kde_f5_init_package "${_variant}" "kcoreaddons"
pkgver=5.68.0
pkgrel=1
arch=('any')
pkgdesc="Classes built on top of QtCore to perform various tasks (mingw-w64-qt5${_namesuff})"
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-extra-cmake-modules>=${pkgver}")
depends=()
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-qt5${_namesuff}"
optdepends=("${MINGW_PACKAGE_PREFIX}-shared-mime-info: Provides information about file types")
groups=('kf5')
source=("https://download.kde.org/stable/frameworks/${pkgver%.*}/${_basename}-${pkgver}.tar.xz"
        001-disable-fam-on-windows.patch)
sha256sums=('c578ae30b4161e45e672d613d2d9c5575a849d21909d9817f90a441044df65d7'
            'cce04ffc4ddc00bbc47625ce2979c2c4011822ae3804561e822be26a8eed8175')

prepare() {
  mkdir -p build-${CARCH}${_variant}

  cd ${_basename}-${pkgver}
  patch -p1 -i ${srcdir}/001-disable-fam-on-windows.patch
}

build() {
  local -a extra_config
  cd build-${CARCH}${_variant}
  if [ "${_variant}" = "-static" ]; then
    extra_config+=( -DBUILD_SHARED_LIBS=NO )
  fi

  _kde_f5_build_env
  cmake ../${_basename}-${pkgver} \
    -DCMAKE_BUILD_TYPE=$(_kde_f5_CMAKE_BUILD_TYPE) \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_QCH=OFF \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    "${extra_config[@]}" \
    -G'MSYS Makefiles'
  make
}

package() {
  cd build-${CARCH}${_variant}
  make DESTDIR="${pkgdir}" install
}
